package cn.liumouren.jzxd.controller;


import cn.liumouren.jzxd.common.utils.PageUtils;
import cn.liumouren.jzxd.common.utils.R;
import cn.liumouren.jzxd.entity.SceneManagerApply;
import cn.liumouren.jzxd.service.SceneManagerApplyService;
import cn.liumouren.jzxd.utils.QueryUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * 景点管理员申请表(Scenemanagerapply)表控制层
 *
 * @author makejava
 * @since 2021-01-20 16:15:38
 */
@RestController
@RequestMapping("/sceneManagerApply")
@Api(tags = "景点管理员申请")
public class SceneManagerApplyController {

    @Autowired
    private SceneManagerApplyService sceneManagerApplyService;

    @ApiOperation("万能查询")
    @RequestMapping(value = "/customQuery", method = RequestMethod.GET)
    public R getSceneNames(@RequestParam Map<String, Object> map) {
        PageUtils result = QueryUtil.getResult(sceneManagerApplyService, map);
        return R.ok("查询成功", result);
    }

    /**
     * 根据id查询
     */
    @GetMapping("/{id}")
    @ApiOperation("根据id查询")
    public R findById(@PathVariable Serializable id) {
        return R.ok().put("data", sceneManagerApplyService.getById(id));
    }

    /**
     * 新增
     */
    @PostMapping("/save")
    @ApiOperation("新增")
    public R save(@RequestBody SceneManagerApply scenemanagerapply) {
        return sceneManagerApplyService.save(scenemanagerapply) ? R.ok() : R.error();
    }

    /**
     * 修改
     */
    @PutMapping
    @ApiOperation("修改")
    public R update(@RequestBody SceneManagerApply scenemanagerapply) {
        return sceneManagerApplyService.updateById(scenemanagerapply) ? R.ok() : R.error("该用户已经是景点管理员");
    }

    /**
     * 批量删除
     */
    @DeleteMapping
    @ApiOperation("批量删除")
    public R delete(@RequestParam("idList") List<Serializable> idList) {
        return sceneManagerApplyService.removeByIds(idList) ? R.ok() : R.error();
    }


}